home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / lispref.info-14 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  49.6 KB  |  1,213 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo-1.63
  2. from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995
  12.  
  13.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  14. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  15. Copyright (C) 1995 Amdahl Corporation.  Copyright (C) 1995 Ben Wing.
  16.  
  17.    Permission is granted to make and distribute verbatim copies of this
  18. manual provided the copyright notice and this permission notice are
  19. preserved on all copies.
  20.  
  21.    Permission is granted to copy and distribute modified versions of
  22. this manual under the conditions for verbatim copying, provided that the
  23. entire resulting derived work is distributed under the terms of a
  24. permission notice identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that this permission notice may be stated in a
  29. translation approved by the Foundation.
  30.  
  31.    Permission is granted to copy and distribute modified versions of
  32. this manual under the conditions for verbatim copying, provided also
  33. that the section entitled "GNU General Public License" is included
  34. exactly as in the original, and provided that the entire resulting
  35. derived work is distributed under the terms of a permission notice
  36. identical to this one.
  37.  
  38.    Permission is granted to copy and distribute translations of this
  39. manual into another language, under the above conditions for modified
  40. versions, except that the section entitled "GNU General Public License"
  41. may be included in a translation approved by the Free Software
  42. Foundation instead of in the original English.
  43.  
  44. 
  45. File: lispref.info,  Node: Minibuffer Completion,  Next: Completion Commands,  Prev: Basic Completion,  Up: Completion
  46.  
  47. Completion and the Minibuffer
  48. -----------------------------
  49.  
  50.    This section describes the basic interface for reading from the
  51. minibuffer with completion.
  52.  
  53.  - Function: completing-read PROMPT COLLECTION &optional PREDICATE
  54.           REQUIRE-MATCH INITIAL HIST
  55.      This function reads a string in the minibuffer, assisting the user
  56.      by providing completion.  It activates the minibuffer with prompt
  57.      PROMPT, which must be a string.  If INITIAL is non-`nil',
  58.      `completing-read' inserts it into the minibuffer as part of the
  59.      input.  Then it allows the user to edit the input, providing
  60.      several commands to attempt completion.
  61.  
  62.      The actual completion is done by passing COLLECTION and PREDICATE
  63.      to the function `try-completion'.  This happens in certain
  64.      commands bound in the local keymaps used for completion.
  65.  
  66.      If REQUIRE-MATCH is `t', the usual minibuffer exit commands won't
  67.      exit unless the input completes to an element of COLLECTION.  If
  68.      REQUIRE-MATCH is neither `nil' nor `t', then the exit commands
  69.      won't exit unless the input typed is itself an element of
  70.      COLLECTION.  If REQUIRE-MATCH is `nil', the exit commands work
  71.      regardless of the input in the minibuffer.
  72.  
  73.      The user can exit with null input by typing RET with an empty
  74.      minibuffer.  Then `completing-read' returns `nil'.  This is how
  75.      the user requests whatever default the command uses for the value
  76.      being read.  The user can return using RET in this way regardless
  77.      of the value of REQUIRE-MATCH.
  78.  
  79.      The function `completing-read' works by calling `read-minibuffer'.
  80.      It uses `minibuffer-local-completion-map' as the keymap if
  81.      REQUIRE-MATCH is `nil', and uses `minibuffer-local-must-match-map'
  82.      if REQUIRE-MATCH is non-`nil'.  *Note Completion Commands::.
  83.  
  84.      The argument HIST specifies which history list variable to use for
  85.      saving the input and for minibuffer history commands.  It defaults
  86.      to `minibuffer-history'.  *Note Minibuffer History::.
  87.  
  88.      Completion ignores case when comparing the input against the
  89.      possible matches, if the built-in variable
  90.      `completion-ignore-case' is non-`nil'.  *Note Basic Completion::.
  91.  
  92.      Here's an example of using `completing-read':
  93.  
  94.           (completing-read
  95.            "Complete a foo: "
  96.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
  97.            nil t "fo")
  98.  
  99.           ;; After evaluation of the preceding expression,
  100.           ;;   the following appears in the minibuffer:
  101.           
  102.           ---------- Buffer: Minibuffer ----------
  103.           Complete a foo: fo-!-
  104.           ---------- Buffer: Minibuffer ----------
  105.  
  106.      If the user then types `DEL DEL b RET', `completing-read' returns
  107.      `barfoo'.
  108.  
  109.      The `completing-read' function binds three variables to pass
  110.      information to the commands that actually do completion.  These
  111.      variables are `minibuffer-completion-table',
  112.      `minibuffer-completion-predicate' and
  113.      `minibuffer-completion-confirm'.  For more information about them,
  114.      see *Note Completion Commands::.
  115.  
  116. 
  117. File: lispref.info,  Node: Completion Commands,  Next: High-Level Completion,  Prev: Minibuffer Completion,  Up: Completion
  118.  
  119. Minibuffer Commands That Do Completion
  120. --------------------------------------
  121.  
  122.    This section describes the keymaps, commands and user options used in
  123. the minibuffer to do completion.
  124.  
  125.  - Variable: minibuffer-local-completion-map
  126.      `completing-read' uses this value as the local keymap when an
  127.      exact match of one of the completions is not required.  By
  128.      default, this keymap makes the following bindings:
  129.  
  130.     `?'
  131.           `minibuffer-completion-help'
  132.  
  133.     SPC
  134.           `minibuffer-complete-word'
  135.  
  136.     TAB
  137.           `minibuffer-complete'
  138.  
  139.      with other characters bound as in `minibuffer-local-map' (*note
  140.      Text from Minibuffer::.).
  141.  
  142.  - Variable: minibuffer-local-must-match-map
  143.      `completing-read' uses this value as the local keymap when an
  144.      exact match of one of the completions is required.  Therefore, no
  145.      keys are bound to `exit-minibuffer', the command that exits the
  146.      minibuffer unconditionally.  By default, this keymap makes the
  147.      following bindings:
  148.  
  149.     `?'
  150.           `minibuffer-completion-help'
  151.  
  152.     SPC
  153.           `minibuffer-complete-word'
  154.  
  155.     TAB
  156.           `minibuffer-complete'
  157.  
  158.     LFD
  159.           `minibuffer-complete-and-exit'
  160.  
  161.     RET
  162.           `minibuffer-complete-and-exit'
  163.  
  164.      with other characters bound as in `minibuffer-local-map'.
  165.  
  166.  - Variable: minibuffer-completion-table
  167.      The value of this variable is the alist or obarray used for
  168.      completion in the minibuffer.  This is the global variable that
  169.      contains what `completing-read' passes to `try-completion'.  It is
  170.      used by minibuffer completion commands such as
  171.      `minibuffer-complete-word'.
  172.  
  173.  - Variable: minibuffer-completion-predicate
  174.      This variable's value is the predicate that `completing-read'
  175.      passes to `try-completion'.  The variable is also used by the other
  176.      minibuffer completion functions.
  177.  
  178.  - Command: minibuffer-complete-word
  179.      This function completes the minibuffer contents by at most a single
  180.      word.  Even if the minibuffer contents have only one completion,
  181.      `minibuffer-complete-word' does not add any characters beyond the
  182.      first character that is not a word constituent.  *Note Syntax
  183.      Tables::.
  184.  
  185.  - Command: minibuffer-complete
  186.      This function completes the minibuffer contents as far as possible.
  187.  
  188.  - Command: minibuffer-complete-and-exit
  189.      This function completes the minibuffer contents, and exits if
  190.      confirmation is not required, i.e., if
  191.      `minibuffer-completion-confirm' is non-`nil'.  If confirmation
  192.      *is* required, it is given by repeating this command
  193.      immediately--the command is programmed to work without confirmation
  194.      when run twice in succession.
  195.  
  196.  - Variable: minibuffer-completion-confirm
  197.      When the value of this variable is non-`nil', XEmacs asks for
  198.      confirmation of a completion before exiting the minibuffer.  The
  199.      function `minibuffer-complete-and-exit' checks the value of this
  200.      variable before it exits.
  201.  
  202.  - Command: minibuffer-completion-help
  203.      This function creates a list of the possible completions of the
  204.      current minibuffer contents.  It works by calling `all-completions'
  205.      using the value of the variable `minibuffer-completion-table' as
  206.      the COLLECTION argument, and the value of
  207.      `minibuffer-completion-predicate' as the PREDICATE argument.  The
  208.      list of completions is displayed as text in a buffer named
  209.      `*Completions*'.
  210.  
  211.  - Function: display-completion-list COMPLETIONS
  212.      This function displays COMPLETIONS to the stream in
  213.      `standard-output', usually a buffer.  (*Note Read and Print::, for
  214.      more information about streams.)  The argument COMPLETIONS is
  215.      normally a list of completions just returned by `all-completions',
  216.      but it does not have to be.  Each element may be a symbol or a
  217.      string, either of which is simply printed, or a list of two
  218.      strings, which is printed as if the strings were concatenated.
  219.  
  220.      This function is called by `minibuffer-completion-help'.  The most
  221.      common way to use it is together with
  222.      `with-output-to-temp-buffer', like this:
  223.  
  224.           (with-output-to-temp-buffer "*Completions*"
  225.             (display-completion-list
  226.               (all-completions (buffer-string) my-alist)))
  227.  
  228.  - User Option: completion-auto-help
  229.      If this variable is non-`nil', the completion commands
  230.      automatically display a list of possible completions whenever
  231.      nothing can be completed because the next character is not
  232.      uniquely determined.
  233.  
  234. 
  235. File: lispref.info,  Node: High-Level Completion,  Next: Reading File Names,  Prev: Completion Commands,  Up: Completion
  236.  
  237. High-Level Completion  Functions
  238. --------------------------------
  239.  
  240.    This section describes the higher-level convenient functions for
  241. reading certain sorts of names with completion.
  242.  
  243.    In most cases, you should not call these functions in the middle of a
  244. Lisp function.  When possible, do all minibuffer input as part of
  245. reading the arguments for a command, in the `interactive' spec.  *Note
  246. Defining Commands::.
  247.  
  248.  - Function: read-buffer PROMPT &optional DEFAULT EXISTING
  249.      This function reads the name of a buffer and returns it as a
  250.      string.  The argument DEFAULT is the default name to use, the
  251.      value to return if the user exits with an empty minibuffer.  If
  252.      non-`nil', it should be a string or a buffer.  It is mentioned in
  253.      the prompt, but is not inserted in the minibuffer as initial input.
  254.  
  255.      If EXISTING is non-`nil', then the name specified must be that of
  256.      an existing buffer.  The usual commands to exit the minibuffer do
  257.      not exit if the text is not valid, and RET does completion to
  258.      attempt to find a valid name.  (However, DEFAULT is not checked
  259.      for validity; it is returned, whatever it is, if the user exits
  260.      with the minibuffer empty.)
  261.  
  262.      In the following example, the user enters `minibuffer.t', and then
  263.      types RET.  The argument EXISTING is `t', and the only buffer name
  264.      starting with the given input is `minibuffer.texi', so that name
  265.      is the value.
  266.  
  267.           (read-buffer "Buffer name? " "foo" t)
  268.           ;; After evaluation of the preceding expression,
  269.           ;;   the following prompt appears,
  270.           ;;   with an empty minibuffer:
  271.           
  272.           ---------- Buffer: Minibuffer ----------
  273.           Buffer name? (default foo) -!-
  274.           ---------- Buffer: Minibuffer ----------
  275.           
  276.           ;; The user types `minibuffer.t RET'.
  277.                => "minibuffer.texi"
  278.  
  279.  - Function: read-command PROMPT
  280.      This function reads the name of a command and returns it as a Lisp
  281.      symbol.  The argument PROMPT is used as in `read-from-minibuffer'.
  282.      Recall that a command is anything for which `commandp' returns
  283.      `t', and a command name is a symbol for which `commandp' returns
  284.      `t'.  *Note Interactive Call::.
  285.  
  286.           (read-command "Command name? ")
  287.           
  288.           ;; After evaluation of the preceding expression,
  289.           ;;   the following prompt appears with an empty minibuffer:
  290.           
  291.           ---------- Buffer: Minibuffer ----------
  292.           Command name?
  293.           ---------- Buffer: Minibuffer ----------
  294.  
  295.      If the user types `forward-c RET', then this function returns
  296.      `forward-char'.
  297.  
  298.      The `read-command' function is a simplified interface to the
  299.      function `completing-read'.  It uses the variable `obarray' so as
  300.      to complete in the set of extant Lisp symbols, and it uses the
  301.      `commandp' predicate so as to accept only command names:
  302.  
  303.           (read-command PROMPT)
  304.           ==
  305.           (intern (completing-read PROMPT obarray
  306.                                    'commandp t nil))
  307.  
  308.  - Function: read-variable PROMPT
  309.      This function reads the name of a user variable and returns it as a
  310.      symbol.
  311.  
  312.           (read-variable "Variable name? ")
  313.           
  314.           ;; After evaluation of the preceding expression,
  315.           ;;   the following prompt appears,
  316.           ;;   with an empty minibuffer:
  317.           
  318.           ---------- Buffer: Minibuffer ----------
  319.           Variable name? -!-
  320.           ---------- Buffer: Minibuffer ----------
  321.  
  322.      If the user then types `fill-p RET', `read-variable' returns
  323.      `fill-prefix'.
  324.  
  325.      This function is similar to `read-command', but uses the predicate
  326.      `user-variable-p' instead of `commandp':
  327.  
  328.           (read-variable PROMPT)
  329.           ==
  330.           (intern
  331.            (completing-read PROMPT obarray
  332.                             'user-variable-p t nil))
  333.  
  334. 
  335. File: lispref.info,  Node: Reading File Names,  Next: Programmed Completion,  Prev: High-Level Completion,  Up: Completion
  336.  
  337. Reading File Names
  338. ------------------
  339.  
  340.    Here is another high-level completion function, designed for reading
  341. a file name.  It provides special features including automatic insertion
  342. of the default directory.
  343.  
  344.  - Function: read-file-name PROMPT &optional DIRECTORY DEFAULT EXISTING
  345.           INITIAL
  346.      This function reads a file name in the minibuffer, prompting with
  347.      PROMPT and providing completion.  If DEFAULT is non-`nil', then
  348.      the function returns DEFAULT if the user just types RET.  DEFAULT
  349.      is not checked for validity; it is returned, whatever it is, if
  350.      the user exits with the minibuffer empty.
  351.  
  352.      If EXISTING is non-`nil', then the user must specify the name of
  353.      an existing file; RET performs completion to make the name valid
  354.      if possible, and then refuses to exit if it is not valid.  If the
  355.      value of EXISTING is neither `nil' nor `t', then RET also requires
  356.      confirmation after completion.  If EXISTING is `nil', then the
  357.      name of a nonexistent file is acceptable.
  358.  
  359.      The argument DIRECTORY specifies the directory to use for
  360.      completion of relative file names.  If `insert-default-directory'
  361.      is non-`nil', DIRECTORY is also inserted in the minibuffer as
  362.      initial input.  It defaults to the current buffer's value of
  363.      `default-directory'.
  364.  
  365.      If you specify INITIAL, that is an initial file name to insert in
  366.      the buffer (after with DIRECTORY, if that is inserted).  In this
  367.      case, point goes at the beginning of INITIAL.  The default for
  368.      INITIAL is `nil'--don't insert any file name.  To see what INITIAL
  369.      does, try the command `C-x C-v'.
  370.  
  371.      Here is an example:
  372.  
  373.           (read-file-name "The file is ")
  374.           
  375.           ;; After evaluation of the preceding expression,
  376.           ;;   the following appears in the minibuffer:
  377.           
  378.           ---------- Buffer: Minibuffer ----------
  379.           The file is /gp/gnu/elisp/-!-
  380.           ---------- Buffer: Minibuffer ----------
  381.  
  382.      Typing `manual TAB' results in the following:
  383.  
  384.           ---------- Buffer: Minibuffer ----------
  385.           The file is /gp/gnu/elisp/manual.texi-!-
  386.           ---------- Buffer: Minibuffer ----------
  387.  
  388.      If the user types RET, `read-file-name' returns the file name as
  389.      the string `"/gp/gnu/elisp/manual.texi"'.
  390.  
  391.  - User Option: insert-default-directory
  392.      This variable is used by `read-file-name'.  Its value controls
  393.      whether `read-file-name' starts by placing the name of the default
  394.      directory in the minibuffer, plus the initial file name if any.
  395.      If the value of this variable is `nil', then `read-file-name' does
  396.      not place any initial input in the minibuffer (unless you specify
  397.      initial input with the INITIAL argument).  In that case, the
  398.      default directory is still used for completion of relative file
  399.      names, but is not displayed.
  400.  
  401.      For example:
  402.  
  403.           ;; Here the minibuffer starts out with the default directory.
  404.           (let ((insert-default-directory t))
  405.             (read-file-name "The file is "))
  406.           
  407.           ---------- Buffer: Minibuffer ----------
  408.           The file is ~lewis/manual/-!-
  409.           ---------- Buffer: Minibuffer ----------
  410.           
  411.           ;; Here the minibuffer is empty and only the prompt
  412.           ;;   appears on its line.
  413.           (let ((insert-default-directory nil))
  414.             (read-file-name "The file is "))
  415.           
  416.           ---------- Buffer: Minibuffer ----------
  417.           The file is -!-
  418.           ---------- Buffer: Minibuffer ----------
  419.  
  420. 
  421. File: lispref.info,  Node: Programmed Completion,  Prev: Reading File Names,  Up: Completion
  422.  
  423. Programmed Completion
  424. ---------------------
  425.  
  426.    Sometimes it is not possible to create an alist or an obarray
  427. containing all the intended possible completions.  In such a case, you
  428. can supply your own function to compute the completion of a given
  429. string.  This is called "programmed completion".
  430.  
  431.    To use this feature, pass a symbol with a function definition as the
  432. COLLECTION argument to `completing-read'.  The function
  433. `completing-read' arranges to pass your completion function along to
  434. `try-completion' and `all-completions', which will then let your
  435. function do all the work.
  436.  
  437.    The completion function should accept three arguments:
  438.  
  439.    * The string to be completed.
  440.  
  441.    * The predicate function to filter possible matches, or `nil' if
  442.      none.  Your function should call the predicate for each possible
  443.      match, and ignore the possible match if the predicate returns
  444.      `nil'.
  445.  
  446.    * A flag specifying the type of operation.
  447.  
  448.    There are three flag values for three operations:
  449.  
  450.    * `nil' specifies `try-completion'.  The completion function should
  451.      return the completion of the specified string, or `t' if the
  452.      string is an exact match already, or `nil' if the string matches no
  453.      possibility.
  454.  
  455.    * `t' specifies `all-completions'.  The completion function should
  456.      return a list of all possible completions of the specified string.
  457.  
  458.    * `lambda' specifies a test for an exact match.  The completion
  459.      function should return `t' if the specified string is an exact
  460.      match for some possibility; `nil' otherwise.
  461.  
  462.    It would be consistent and clean for completion functions to allow
  463. lambda expressions (lists that are functions) as well as function
  464. symbols as COLLECTION, but this is impossible.  Lists as completion
  465. tables are already assigned another meaning--as alists.  It would be
  466. unreliable to fail to handle an alist normally because it is also a
  467. possible function.  So you must arrange for any function you wish to
  468. use for completion to be encapsulated in a symbol.
  469.  
  470.    Emacs uses programmed completion when completing file names.  *Note
  471. File Name Completion::.
  472.  
  473. 
  474. File: lispref.info,  Node: Yes-or-No Queries,  Next: Multiple Queries,  Prev: Completion,  Up: Minibuffers
  475.  
  476. Yes-or-No Queries
  477. =================
  478.  
  479.    This section describes functions used to ask the user a yes-or-no
  480. question.  The function `y-or-n-p' can be answered with a single
  481. character; it is useful for questions where an inadvertent wrong answer
  482. will not have serious consequences.  `yes-or-no-p' is suitable for more
  483. momentous questions, since it requires three or four characters to
  484. answer.  Variations of these functions can be used to ask a yes-or-no
  485. question using a dialog box, or optionally using one.
  486.  
  487.    If either of these functions is called in a command that was invoked
  488. using the mouse, then it uses a dialog box or pop-up menu to ask the
  489. question.  Otherwise, it uses keyboard input.
  490.  
  491.    Strictly speaking, `yes-or-no-p' uses the minibuffer and `y-or-n-p'
  492. does not; but it seems best to describe them together.
  493.  
  494.  - Function: y-or-n-p PROMPT
  495.      This function asks the user a question, expecting input in the echo
  496.      area.  It returns `t' if the user types `y', `nil' if the user
  497.      types `n'.  This function also accepts SPC to mean yes and DEL to
  498.      mean no.  It accepts `C-]' to mean "quit", like `C-g', because the
  499.      question might look like a minibuffer and for that reason the user
  500.      might try to use `C-]' to get out.  The answer is a single
  501.      character, with no RET needed to terminate it.  Upper and lower
  502.      case are equivalent.
  503.  
  504.      "Asking the question" means printing PROMPT in the echo area,
  505.      followed by the string `(y or n) '.  If the input is not one of
  506.      the expected answers (`y', `n', `SPC', `DEL', or something that
  507.      quits), the function responds `Please answer y or n.', and repeats
  508.      the request.
  509.  
  510.      This function does not actually use the minibuffer, since it does
  511.      not allow editing of the answer.  It actually uses the echo area
  512.      (*note The Echo Area::.), which uses the same screen space as the
  513.      minibuffer.  The cursor moves to the echo area while the question
  514.      is being asked.
  515.  
  516.      The answers and their meanings, even `y' and `n', are not
  517.      hardwired.  The keymap `query-replace-map' specifies them.  *Note
  518.      Search and Replace::.
  519.  
  520.      In the following example, the user first types `q', which is
  521.      invalid.  At the next prompt the user types `y'.
  522.  
  523.           (y-or-n-p "Do you need a lift? ")
  524.           
  525.           ;; After evaluation of the preceding expression,
  526.           ;;   the following prompt appears in the echo area:
  527.  
  528.           ---------- Echo area ----------
  529.           Do you need a lift? (y or n)
  530.           ---------- Echo area ----------
  531.           
  532.           ;; If the user then types `q', the following appears:
  533.           ---------- Echo area ----------
  534.           Please answer y or n.  Do you need a lift? (y or n)
  535.           ---------- Echo area ----------
  536.           
  537.           ;; When the user types a valid answer,
  538.           ;;   it is displayed after the question:
  539.           ---------- Echo area ----------
  540.           Do you need a lift? (y or n) y
  541.           ---------- Echo area ----------
  542.  
  543.      We show successive lines of echo area messages, but only one
  544.      actually appears on the screen at a time.
  545.  
  546.  - Function: yes-or-no-p PROMPT
  547.      This function asks the user a question, expecting input in the
  548.      minibuffer.  It returns `t' if the user enters `yes', `nil' if the
  549.      user types `no'.  The user must type RET to finalize the response.
  550.      Upper and lower case are equivalent.
  551.  
  552.      `yes-or-no-p' starts by displaying PROMPT in the echo area,
  553.      followed by `(yes or no) '.  The user must type one of the
  554.      expected responses; otherwise, the function responds `Please answer
  555.      yes or no.', waits about two seconds and repeats the request.
  556.  
  557.      `yes-or-no-p' requires more work from the user than `y-or-n-p' and
  558.      is appropriate for more crucial decisions.
  559.  
  560.      Here is an example:
  561.  
  562.           (yes-or-no-p "Do you really want to remove everything? ")
  563.           
  564.           ;; After evaluation of the preceding expression,
  565.           ;;   the following prompt appears,
  566.           ;;   with an empty minibuffer:
  567.  
  568.           ---------- Buffer: minibuffer ----------
  569.           Do you really want to remove everything? (yes or no)
  570.           ---------- Buffer: minibuffer ----------
  571.  
  572.      If the user first types `y RET', which is invalid because this
  573.      function demands the entire word `yes', it responds by displaying
  574.      these prompts, with a brief pause between them:
  575.  
  576.           ---------- Buffer: minibuffer ----------
  577.           Please answer yes or no.
  578.           Do you really want to remove everything? (yes or no)
  579.           ---------- Buffer: minibuffer ----------
  580.  
  581.  - Function: yes-or-no-p-dialog-box PROMPT
  582.      This function asks the user a "y or n" question with a popup dialog
  583.      box.  It returns `t' if the answer is "yes".  PROMPT is the string
  584.      to display to ask the question.
  585.  
  586.    The following functions ask a question either in the minibuffer or a
  587. dialog box, depending on whether the last user event (which presumably
  588. invoked this command) was a keyboard or mouse event.  When XEmacs is
  589. running on a window system, the functions `y-or-n-p' and `yes-or-no-p'
  590. are replaced with the following functions, so that menu items bring up
  591. dialog boxes instead of minibuffer questions.
  592.  
  593.  - Function: y-or-n-p-maybe-dialog-box PROMPT
  594.      This function asks user a "y or n" question, using either a dialog
  595.      box or the minibuffer, as appropriate.
  596.  
  597.  - Function: yes-or-no-p-maybe-dialog-box PROMPT
  598.      This function asks user a "yes or no" question, using either a
  599.      dialog box or the minibuffer, as appropriate.
  600.  
  601. 
  602. File: lispref.info,  Node: Multiple Queries,  Next: Minibuffer Misc,  Prev: Yes-or-No Queries,  Up: Minibuffers
  603.  
  604. Asking Multiple Y-or-N Questions
  605. ================================
  606.  
  607.    When you have a series of similar questions to ask, such as "Do you
  608. want to save this buffer" for each buffer in turn, you should use
  609. `map-y-or-n-p' to ask the collection of questions, rather than asking
  610. each question individually.  This gives the user certain convenient
  611. facilities such as the ability to answer the whole series at once.
  612.  
  613.  - Function: map-y-or-n-p PROMPTER ACTOR LIST &optional HELP
  614.           ACTION-ALIST
  615.      This function, new in Emacs 19, asks the user a series of
  616.      questions, reading a single-character answer in the echo area for
  617.      each one.
  618.  
  619.      The value of LIST specifies the objects to ask questions about.
  620.      It should be either a list of objects or a generator function.  If
  621.      it is a function, it should expect no arguments, and should return
  622.      either the next object to ask about, or `nil' meaning stop asking
  623.      questions.
  624.  
  625.      The argument PROMPTER specifies how to ask each question.  If
  626.      PROMPTER is a string, the question text is computed like this:
  627.  
  628.           (format PROMPTER OBJECT)
  629.  
  630.      where OBJECT is the next object to ask about (as obtained from
  631.      LIST).
  632.  
  633.      If not a string, PROMPTER should be a function of one argument
  634.      (the next object to ask about) and should return the question
  635.      text.  If the value is a string, that is the question to ask the
  636.      user.  The function can also return `t' meaning do act on this
  637.      object (and don't ask the user), or `nil' meaning ignore this
  638.      object (and don't ask the user).
  639.  
  640.      The argument ACTOR says how to act on the answers that the user
  641.      gives.  It should be a function of one argument, and it is called
  642.      with each object that the user says yes for.  Its argument is
  643.      always an object obtained from LIST.
  644.  
  645.      If the argument HELP is given, it should be a list of this form:
  646.  
  647.           (SINGULAR PLURAL ACTION)
  648.  
  649.      where SINGULAR is a string containing a singular noun that
  650.      describes the objects conceptually being acted on, PLURAL is the
  651.      corresponding plural noun, and ACTION is a transitive verb
  652.      describing what ACTOR does.
  653.  
  654.      If you don't specify HELP, the default is `("object" "objects"
  655.      "act on")'.
  656.  
  657.      Each time a question is asked, the user may enter `y', `Y', or SPC
  658.      to act on that object; `n', `N', or DEL to skip that object; `!'
  659.      to act on all following objects; ESC or `q' to exit (skip all
  660.      following objects); `.' (period) to act on the current object and
  661.      then exit; or `C-h' to get help.  These are the same answers that
  662.      `query-replace' accepts.  The keymap `query-replace-map' defines
  663.      their meaning for `map-y-or-n-p' as well as for `query-replace';
  664.      see *Note Search and Replace::.
  665.  
  666.      You can use ACTION-ALIST to specify additional possible answers
  667.      and what they mean.  It is an alist of elements of the form `(CHAR
  668.      FUNCTION HELP)', each of which defines one additional answer.  In
  669.      this element, CHAR is a character (the answer); FUNCTION is a
  670.      function of one argument (an object from LIST); HELP is a string.
  671.  
  672.      When the user responds with CHAR, `map-y-or-n-p' calls FUNCTION.
  673.      If it returns non-`nil', the object is considered "acted upon",
  674.      and `map-y-or-n-p' advances to the next object in LIST.  If it
  675.      returns `nil', the prompt is repeated for the same object.
  676.  
  677.      If `map-y-or-n-p' is called in a command that was invoked using the
  678.      mouse--more precisely, if `last-nonmenu-event' (*note Command Loop
  679.      Info::.) is either `nil' or a list--then it uses a dialog box or
  680.      pop-up menu to ask the question.  In this case, it does not use
  681.      keyboard input or the echo area.  You can force use of the mouse
  682.      or use of keyboard input by binding `last-nonmenu-event' to a
  683.      suitable value around the call.
  684.  
  685.      The return value of `map-y-or-n-p' is the number of objects acted
  686.      on.
  687.  
  688. 
  689. File: lispref.info,  Node: Minibuffer Misc,  Prev: Multiple Queries,  Up: Minibuffers
  690.  
  691. Minibuffer Miscellany
  692. =====================
  693.  
  694.    This section describes some basic functions and variables related to
  695. minibuffers.
  696.  
  697.  - Command: exit-minibuffer
  698.      This command exits the active minibuffer.  It is normally bound to
  699.      keys in minibuffer local keymaps.
  700.  
  701.  - Command: self-insert-and-exit
  702.      This command exits the active minibuffer after inserting the last
  703.      character typed on the keyboard (found in `last-command-char';
  704.      *note Command Loop Info::.).
  705.  
  706.  - Command: previous-history-element N
  707.      This command replaces the minibuffer contents with the value of the
  708.      Nth previous (older) history element.
  709.  
  710.  - Command: next-history-element N
  711.      This command replaces the minibuffer contents with the value of the
  712.      Nth more recent history element.
  713.  
  714.  - Command: previous-matching-history-element PATTERN
  715.      This command replaces the minibuffer contents with the value of the
  716.      previous (older) history element that matches PATTERN (a regular
  717.      expression).
  718.  
  719.  - Command: next-matching-history-element PATTERN
  720.      This command replaces the minibuffer contents with the value of
  721.      the next (newer) history element that matches PATTERN (a regular
  722.      expression).
  723.  
  724.  - Function: minibuffer-prompt
  725.      This function returns the prompt string of the currently active
  726.      minibuffer.  If no minibuffer is active, it returns `nil'.
  727.  
  728.  - Function: minibuffer-prompt-width
  729.      This function returns the display width of the prompt string of the
  730.      currently active minibuffer.  If no minibuffer is active, it
  731.      returns 0.
  732.  
  733.  - Variable: minibuffer-setup-hook
  734.      This is a normal hook that is run whenever the minibuffer is
  735.      entered.  *Note Hooks::.
  736.  
  737.  - Variable: minibuffer-exit-hook
  738.      This is a normal hook that is run whenever the minibuffer is
  739.      exited.  *Note Hooks::.
  740.  
  741.  - Variable: minibuffer-help-form
  742.      The current value of this variable is used to rebind `help-form'
  743.      locally inside the minibuffer (*note Help Functions::.).
  744.  
  745.  - Function: active-minibuffer-window
  746.      This function returns the currently active minibuffer window, or
  747.      `nil' if none is currently active.
  748.  
  749.  - Function: minibuffer-window &optional FRAME
  750.      This function returns the minibuffer window used for frame FRAME.
  751.      If FRAME is `nil', that stands for the current frame.  Note that
  752.      the minibuffer window used by a frame need not be part of that
  753.      frame--a frame that has no minibuffer of its own necessarily uses
  754.      some other frame's minibuffer window.
  755.  
  756.  - Function: window-minibuffer-p WINDOW
  757.      This function returns non-`nil' if WINDOW is a minibuffer window.
  758.  
  759.    It is not correct to determine whether a given window is a
  760. minibuffer by comparing it with the result of `(minibuffer-window)',
  761. because there can be more than one minibuffer window if there is more
  762. than one frame.
  763.  
  764.  - Function: minibuffer-window-active-p WINDOW
  765.      This function returns non-`nil' if WINDOW, assumed to be a
  766.      minibuffer window, is currently active.
  767.  
  768.  - Variable: minibuffer-scroll-window
  769.      If the value of this variable is non-`nil', it should be a window
  770.      object.  When the function `scroll-other-window' is called in the
  771.      minibuffer, it scrolls this window.
  772.  
  773.    Finally, some functions and variables deal with recursive minibuffers
  774. (*note Recursive Editing::.):
  775.  
  776.  - Function: minibuffer-depth
  777.      This function returns the current depth of activations of the
  778.      minibuffer, a nonnegative integer.  If no minibuffers are active,
  779.      it returns zero.
  780.  
  781.  - User Option: enable-recursive-minibuffers
  782.      If this variable is non-`nil', you can invoke commands (such as
  783.      `find-file') that use minibuffers even while in the minibuffer
  784.      window.  Such invocation produces a recursive editing level for a
  785.      new minibuffer.  The outer-level minibuffer is invisible while you
  786.      are editing the inner one.
  787.  
  788.      This variable only affects invoking the minibuffer while the
  789.      minibuffer window is selected.   If you switch windows while in the
  790.      minibuffer, you can always invoke minibuffer commands while some
  791.      other window is selected.
  792.  
  793.    If a command name has a property `enable-recursive-minibuffers' that
  794. is non-`nil', then the command can use the minibuffer to read arguments
  795. even if it is invoked from the minibuffer.  The minibuffer command
  796. `next-matching-history-element' (normally `M-s' in the minibuffer) uses
  797. this feature.
  798.  
  799. 
  800. File: lispref.info,  Node: Command Loop,  Next: Keymaps,  Prev: Minibuffers,  Up: Top
  801.  
  802. Command Loop
  803. ************
  804.  
  805.    When you run XEmacs, it enters the "editor command loop" almost
  806. immediately.  This loop reads events, executes their definitions, and
  807. displays the results.  In this chapter, we describe how these things
  808. are done, and the subroutines that allow Lisp programs to do them.
  809.  
  810. * Menu:
  811.  
  812. * Command Overview::    How the command loop reads commands.
  813. * Defining Commands::   Specifying how a function should read arguments.
  814. * Interactive Call::    Calling a command, so that it will read arguments.
  815. * Command Loop Info::   Variables set by the command loop for you to examine.
  816. * Events::        What input looks like when you read it.
  817. * Reading Input::       How to read input events from the keyboard or mouse.
  818. * Waiting::             Waiting for user input or elapsed time.
  819. * Quitting::            How `C-g' works.  How to catch or defer quitting.
  820. * Prefix Command Arguments::    How the commands to set prefix args work.
  821. * Recursive Editing::   Entering a recursive edit,
  822.                           and why you usually shouldn't.
  823. * Disabling Commands::  How the command loop handles disabled commands.
  824. * Command History::     How the command history is set up, and how accessed.
  825. * Keyboard Macros::     How keyboard macros are implemented.
  826.  
  827. 
  828. File: lispref.info,  Node: Command Overview,  Next: Defining Commands,  Up: Command Loop
  829.  
  830. Command Loop Overview
  831. =====================
  832.  
  833.    The command loop in XEmacs is a standard event loop, reading events
  834. one at a time with `next-event' and handling them with
  835. `dispatch-event'.  An event is typically a single user action, such as
  836. a keypress, mouse movement, or menu selection; but they can also be
  837. notifications from the window system, informing XEmacs that (for
  838. example) part of its window was just uncovered and needs to be redrawn.
  839. *Note Events::.  Pending events are held in a first-in, first-out list
  840. called the "event queue": events are read from the head of the list,
  841. and newly arriving events are added to the tail.  In this way, events
  842. are always processed in the order in which they arrive.
  843.  
  844.    `dispatch-event' does most of the work of handling user actions.
  845. The first thing it must do is put the events together into a key
  846. sequence, which is a sequence of events that translates into a command.
  847. It does this by consulting the active keymaps, which specify what the
  848. valid key sequences are and how to translate them into commands.  *Note
  849. Key Lookup::, for information on how this is done.  The result of the
  850. translation should be a keyboard macro or an interactively callable
  851. function.  If the key is `M-x', then it reads the name of another
  852. command, which it then calls.  This is done by the command
  853. `execute-extended-command' (*note Interactive Call::.).
  854.  
  855.    To execute a command requires first reading the arguments for it.
  856. This is done by calling `command-execute' (*note Interactive Call::.).
  857. For commands written in Lisp, the `interactive' specification says how
  858. to read the arguments.  This may use the prefix argument (*note Prefix
  859. Command Arguments::.) or may read with prompting in the minibuffer
  860. (*note Minibuffers::.).  For example, the command `find-file' has an
  861. `interactive' specification which says to read a file name using the
  862. minibuffer.  The command's function body does not use the minibuffer;
  863. if you call this command from Lisp code as a function, you must supply
  864. the file name string as an ordinary Lisp function argument.
  865.  
  866.    If the command is a string or vector (i.e., a keyboard macro) then
  867. `execute-kbd-macro' is used to execute it.  You can call this function
  868. yourself (*note Keyboard Macros::.).
  869.  
  870.    To terminate the execution of a running command, type `C-g'.  This
  871. character causes "quitting" (*note Quitting::.).
  872.  
  873.  - Variable: pre-command-hook
  874.      The editor command loop runs this normal hook before each command.
  875.      At that time, `this-command' contains the command that is about to
  876.      run, and `last-command' describes the previous command.  *Note
  877.      Hooks::.
  878.  
  879.  - Variable: post-command-hook
  880.      The editor command loop runs this normal hook after each command.
  881.      (In FSF Emacs, it is also run when the command loop is entered, or
  882.      reentered after an error or quit.)  At that time, `this-command'
  883.      describes the command that just ran, and `last-command' describes
  884.      the command before that.  *Note Hooks::.
  885.  
  886.    Quitting is suppressed while running `pre-command-hook' and
  887. `post-command-hook'.  If an error happens while executing one of these
  888. hooks, it terminates execution of the hook, but that is all it does.
  889.  
  890. 
  891. File: lispref.info,  Node: Defining Commands,  Next: Interactive Call,  Prev: Command Overview,  Up: Command Loop
  892.  
  893. Defining Commands
  894. =================
  895.  
  896.    A Lisp function becomes a command when its body contains, at top
  897. level, a form that calls the special form `interactive'.  This form
  898. does nothing when actually executed, but its presence serves as a flag
  899. to indicate that interactive calling is permitted.  Its argument
  900. controls the reading of arguments for an interactive call.
  901.  
  902. * Menu:
  903.  
  904. * Using Interactive::     General rules for `interactive'.
  905. * Interactive Codes::     The standard letter-codes for reading arguments
  906.                              in various ways.
  907. * Interactive Examples::  Examples of how to read interactive arguments.
  908.  
  909. 
  910. File: lispref.info,  Node: Using Interactive,  Next: Interactive Codes,  Up: Defining Commands
  911.  
  912. Using `interactive'
  913. -------------------
  914.  
  915.    This section describes how to write the `interactive' form that
  916. makes a Lisp function an interactively-callable command.
  917.  
  918.  - Special Form: interactive ARG-DESCRIPTOR
  919.      This special form declares that the function in which it appears
  920.      is a command, and that it may therefore be called interactively
  921.      (via `M-x' or by entering a key sequence bound to it).  The
  922.      argument ARG-DESCRIPTOR declares how to compute the arguments to
  923.      the command when the command is called interactively.
  924.  
  925.      A command may be called from Lisp programs like any other
  926.      function, but then the caller supplies the arguments and
  927.      ARG-DESCRIPTOR has no effect.
  928.  
  929.      The `interactive' form has its effect because the command loop
  930.      (actually, its subroutine `call-interactively') scans through the
  931.      function definition looking for it, before calling the function.
  932.      Once the function is called, all its body forms including the
  933.      `interactive' form are executed, but at this time `interactive'
  934.      simply returns `nil' without even evaluating its argument.
  935.  
  936.    There are three possibilities for the argument ARG-DESCRIPTOR:
  937.  
  938.    * It may be omitted or `nil'; then the command is called with no
  939.      arguments.  This leads quickly to an error if the command requires
  940.      one or more arguments.
  941.  
  942.    * It may be a Lisp expression that is not a string; then it should
  943.      be a form that is evaluated to get a list of arguments to pass to
  944.      the command.
  945.  
  946.      If this expression reads keyboard input (this includes using the
  947.      minibuffer), keep in mind that the integer value of point or the
  948.      mark before reading input may be incorrect after reading input.
  949.      This is because the current buffer may be receiving subprocess
  950.      output; if subprocess output arrives while the command is waiting
  951.      for input, it could relocate point and the mark.
  952.  
  953.      Here's an example of what *not* to do:
  954.  
  955.           (interactive
  956.            (list (region-beginning) (region-end)
  957.                  (read-string "Foo: " nil 'my-history)))
  958.  
  959.      Here's how to avoid the problem, by examining point and the mark
  960.      only after reading the keyboard input:
  961.  
  962.           (interactive
  963.            (let ((string (read-string "Foo: " nil 'my-history)))
  964.              (list (region-beginning) (region-end) string)))
  965.  
  966.    * It may be a string; then its contents should consist of a code
  967.      character followed by a prompt (which some code characters use and
  968.      some ignore).  The prompt ends either with the end of the string
  969.      or with a newline.  Here is a simple example:
  970.  
  971.           (interactive "bFrobnicate buffer: ")
  972.  
  973.      The code letter `b' says to read the name of an existing buffer,
  974.      with completion.  The buffer name is the sole argument passed to
  975.      the command.  The rest of the string is a prompt.
  976.  
  977.      If there is a newline character in the string, it terminates the
  978.      prompt.  If the string does not end there, then the rest of the
  979.      string should contain another code character and prompt,
  980.      specifying another argument.  You can specify any number of
  981.      arguments in this way.
  982.  
  983.      The prompt string can use `%' to include previous argument values
  984.      (starting with the first argument) in the prompt.  This is done
  985.      using `format' (*note Formatting Strings::.).  For example, here
  986.      is how you could read the name of an existing buffer followed by a
  987.      new name to give to that buffer:
  988.  
  989.           (interactive "bBuffer to rename: \nsRename buffer %s to: ")
  990.  
  991.      If the first character in the string is `*', then an error is
  992.      signaled if the buffer is read-only.
  993.  
  994.      If the first character in the string is `@', and if the key
  995.      sequence used to invoke the command includes any mouse events, then
  996.      the window associated with the first of those events is selected
  997.      before the command is run.
  998.  
  999.      If the first character in the string is `_', then this command will
  1000.      not cause the region to be deactivated when it completes; that is,
  1001.      `zmacs-region-stays' will be set to `t' when the command exits
  1002.      successfully.
  1003.  
  1004.      You can use `*', `@', and `_' together; the order does not matter.
  1005.      Actual reading of arguments is controlled by the rest of the
  1006.      prompt string (starting with the first character that is not `*',
  1007.      `@', or `_').
  1008.  
  1009. 
  1010. File: lispref.info,  Node: Interactive Codes,  Next: Interactive Examples,  Prev: Using Interactive,  Up: Defining Commands
  1011.  
  1012. Code Characters for `interactive'
  1013. ---------------------------------
  1014.  
  1015.    The code character descriptions below contain a number of key words,
  1016. defined here as follows:
  1017.  
  1018. Completion
  1019.      Provide completion.  TAB, SPC, and RET perform name completion
  1020.      because the argument is read using `completing-read' (*note
  1021.      Completion::.).  `?' displays a list of possible completions.
  1022.  
  1023. Existing
  1024.      Require the name of an existing object.  An invalid name is not
  1025.      accepted; the commands to exit the minibuffer do not exit if the
  1026.      current input is not valid.
  1027.  
  1028. Default
  1029.      A default value of some sort is used if the user enters no text in
  1030.      the minibuffer.  The default depends on the code character.
  1031.  
  1032. No I/O
  1033.      This code letter computes an argument without reading any input.
  1034.      Therefore, it does not use a prompt string, and any prompt string
  1035.      you supply is ignored.
  1036.  
  1037.      Even though the code letter doesn't use a prompt string, you must
  1038.      follow it with a newline if it is not the last code character in
  1039.      the string.
  1040.  
  1041. Prompt
  1042.      A prompt immediately follows the code character.  The prompt ends
  1043.      either with the end of the string or with a newline.
  1044.  
  1045. Special
  1046.      This code character is meaningful only at the beginning of the
  1047.      interactive string, and it does not look for a prompt or a newline.
  1048.      It is a single, isolated character.
  1049.  
  1050.    Here are the code character descriptions for use with `interactive':
  1051.  
  1052. `*'
  1053.      Signal an error if the current buffer is read-only.  Special.
  1054.  
  1055. `@'
  1056.      Select the window mentioned in the first mouse event in the key
  1057.      sequence that invoked this command.  Special.
  1058.  
  1059. `_'
  1060.      Do not cause the region to be deactivated when this command
  1061.      completes.  Special.
  1062.  
  1063. `a'
  1064.      A function name (i.e., a symbol satisfying `fboundp').  Existing,
  1065.      Completion, Prompt.
  1066.  
  1067. `b'
  1068.      The name of an existing buffer.  By default, uses the name of the
  1069.      current buffer (*note Buffers::.).  Existing, Completion, Default,
  1070.      Prompt.
  1071.  
  1072. `B'
  1073.      A buffer name.  The buffer need not exist.  By default, uses the
  1074.      name of a recently used buffer other than the current buffer.
  1075.      Completion, Default, Prompt.
  1076.  
  1077. `c'
  1078.      A character.  The cursor does not move into the echo area.  Prompt.
  1079.  
  1080. `C'
  1081.      A command name (i.e., a symbol satisfying `commandp').  Existing,
  1082.      Completion, Prompt.
  1083.  
  1084. `d'
  1085.      The position of point, as an integer (*note Point::.).  No I/O.
  1086.  
  1087. `D'
  1088.      A directory name.  The default is the current default directory of
  1089.      the current buffer, `default-directory' (*note System
  1090.      Environment::.).  Existing, Completion, Default, Prompt.
  1091.  
  1092. `e'
  1093.      The last mouse event in the key sequence that invoked the command.
  1094.      No I/O.
  1095.  
  1096. `f'
  1097.      A file name of an existing file (*note File Names::.).  The default
  1098.      directory is `default-directory'.  Existing, Completion, Default,
  1099.      Prompt.
  1100.  
  1101. `F'
  1102.      A file name.  The file need not exist.  Completion, Default,
  1103.      Prompt.
  1104.  
  1105. `k'
  1106.      A key sequence (*note Keymap Terminology::.).  This keeps reading
  1107.      events until a command (or undefined command) is found in the
  1108.      current key maps.  The key sequence argument is represented as a
  1109.      vector of events.  The cursor does not move into the echo area.
  1110.      Prompt.
  1111.  
  1112.      This kind of input is used by commands such as `describe-key' and
  1113.      `global-set-key'.
  1114.  
  1115. `K'
  1116.      A key sequence, whose definition you intend to change.  This works
  1117.      like `k', except that it suppresses, for the last input event in
  1118.      the key sequence, the conversions that are normally used (when
  1119.      necessary) to convert an undefined key into a defined one.
  1120.  
  1121. `m'
  1122.      The position of the mark, as an integer.  No I/O.
  1123.  
  1124. `n'
  1125.      A number read with the minibuffer.  If the input is not a number,
  1126.      the user is asked to try again.  The prefix argument, if any, is
  1127.      not used.  Prompt.
  1128.  
  1129. `N'
  1130.      The raw prefix argument.  If the prefix argument is `nil', then
  1131.      read a number as with `n'.  Requires a number.  *Note Prefix
  1132.      Command Arguments::.  Prompt.
  1133.  
  1134. `p'
  1135.      The numeric prefix argument.  (Note that this `p' is lower case.)
  1136.      No I/O.
  1137.  
  1138. `P'
  1139.      The raw prefix argument.  (Note that this `P' is upper case.)  No
  1140.      I/O.
  1141.  
  1142. `r'
  1143.      Point and the mark, as two numeric arguments, smallest first.
  1144.      This is the only code letter that specifies two successive
  1145.      arguments rather than one.  No I/O.
  1146.  
  1147. `s'
  1148.      Arbitrary text, read in the minibuffer and returned as a string
  1149.      (*note Text from Minibuffer::.).  Terminate the input with either
  1150.      LFD or RET.  (`C-q' may be used to include either of these
  1151.      characters in the input.)  Prompt.
  1152.  
  1153. `S'
  1154.      An interned symbol whose name is read in the minibuffer.  Any
  1155.      whitespace character terminates the input.  (Use `C-q' to include
  1156.      whitespace in the string.)  Other characters that normally
  1157.      terminate a symbol (e.g., parentheses and brackets) do not do so
  1158.      here.  Prompt.
  1159.  
  1160. `v'
  1161.      A variable declared to be a user option (i.e., satisfying the
  1162.      predicate `user-variable-p').  *Note High-Level Completion::.
  1163.      Existing, Completion, Prompt.
  1164.  
  1165. `x'
  1166.      A Lisp object, specified with its read syntax, terminated with a
  1167.      LFD or RET.  The object is not evaluated.  *Note Object from
  1168.      Minibuffer::.  Prompt.
  1169.  
  1170. `X'
  1171.      A Lisp form is read as with `x', but then evaluated so that its
  1172.      value becomes the argument for the command.  Prompt.
  1173.  
  1174. 
  1175. File: lispref.info,  Node: Interactive Examples,  Prev: Interactive Codes,  Up: Defining Commands
  1176.  
  1177. Examples of Using `interactive'
  1178. -------------------------------
  1179.  
  1180.    Here are some examples of `interactive':
  1181.  
  1182.      (defun foo1 ()              ; `foo1' takes no arguments,
  1183.          (interactive)           ;   just moves forward two words.
  1184.          (forward-word 2))
  1185.           => foo1
  1186.      
  1187.      (defun foo2 (n)             ; `foo2' takes one argument,
  1188.          (interactive "p")       ;   which is the numeric prefix.
  1189.          (forward-word (* 2 n)))
  1190.           => foo2
  1191.      
  1192.      (defun foo3 (n)             ; `foo3' takes one argument,
  1193.          (interactive "nCount:") ;   which is read with the Minibuffer.
  1194.          (forward-word (* 2 n)))
  1195.           => foo3
  1196.      
  1197.      (defun three-b (b1 b2 b3)
  1198.        "Select three existing buffers.
  1199.      Put them into three windows, selecting the last one."
  1200.          (interactive "bBuffer1:\nbBuffer2:\nbBuffer3:")
  1201.          (delete-other-windows)
  1202.          (split-window (selected-window) 8)
  1203.          (switch-to-buffer b1)
  1204.          (other-window 1)
  1205.          (split-window (selected-window) 8)
  1206.          (switch-to-buffer b2)
  1207.          (other-window 1)
  1208.          (switch-to-buffer b3))
  1209.           => three-b
  1210.      (three-b "*scratch*" "declarations.texi" "*mail*")
  1211.           => nil
  1212.  
  1213.